Basic Makefile changes for PIE
authorSoby Mathew <[email protected]>
Tue, 28 Aug 2018 10:13:55 +0000 (11:13 +0100)
committerSoby Mathew <[email protected]>
Mon, 29 Oct 2018 09:54:31 +0000 (09:54 +0000)
Change-Id: I0b8ccba15024c55bb03927cdb50370913eb8010c
Signed-off-by: Soby Mathew <[email protected]>
Makefile
docs/user-guide.rst
make_helpers/defaults.mk

index be543facb61ce43e10b4016bb01e44c619ff1238..74d518043363b71c743ba5d54c2a5a50d0c2b3c8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -205,11 +205,6 @@ TF_CFLAGS          +=      $(CPPFLAGS) $(TF_CFLAGS_$(ARCH))                \
                                -Os -ffunction-sections -fdata-sections
 
 GCC_V_OUTPUT           :=      $(shell $(CC) -v 2>&1)
-PIE_FOUND              :=      $(findstring --enable-default-pie,${GCC_V_OUTPUT})
-
-ifneq ($(PIE_FOUND),)
-TF_CFLAGS              +=      -fno-PIE
-endif
 
 # Force the compiler to include the frame pointer
 ifeq (${ENABLE_BACKTRACE},1)
@@ -335,6 +330,16 @@ ifeq (${ARM_ARCH_MAJOR},7)
 include make_helpers/armv7-a-cpus.mk
 endif
 
+ifeq ($(ENABLE_PIE),1)
+    TF_CFLAGS          +=      -fpie
+    TF_LDFLAGS         +=      -pie
+else
+    PIE_FOUND          :=      $(findstring --enable-default-pie,${GCC_V_OUTPUT})
+    ifneq ($(PIE_FOUND),)
+        TF_CFLAGS              +=      -fno-PIE
+    endif
+endif
+
 # Include the CPU specific operations makefile, which provides default
 # values for all CPU errata workarounds and CPU specific optimisations.
 # This can be overridden by the platform.
@@ -565,6 +570,7 @@ $(eval $(call assert_boolean,ENABLE_AMU))
 $(eval $(call assert_boolean,ENABLE_ASSERTIONS))
 $(eval $(call assert_boolean,ENABLE_BACKTRACE))
 $(eval $(call assert_boolean,ENABLE_MPAM_FOR_LOWER_ELS))
+$(eval $(call assert_boolean,ENABLE_PIE))
 $(eval $(call assert_boolean,ENABLE_PMF))
 $(eval $(call assert_boolean,ENABLE_PSCI_STAT))
 $(eval $(call assert_boolean,ENABLE_RUNTIME_INSTRUMENTATION))
@@ -615,6 +621,7 @@ $(eval $(call add_define,ENABLE_AMU))
 $(eval $(call add_define,ENABLE_ASSERTIONS))
 $(eval $(call add_define,ENABLE_BACKTRACE))
 $(eval $(call add_define,ENABLE_MPAM_FOR_LOWER_ELS))
+$(eval $(call add_define,ENABLE_PIE))
 $(eval $(call add_define,ENABLE_PMF))
 $(eval $(call add_define,ENABLE_PSCI_STAT))
 $(eval $(call add_define,ENABLE_RUNTIME_INSTRUMENTATION))
index f4ef85d2a140f0356be80d283683298cbace3d73..52cb45c09a18e799fa4ec8c6bd018fbf7a236986 100644 (file)
@@ -371,6 +371,10 @@ Common build options
    partitioning in EL3, however. Platform initialisation code should configure
    and use partitions in EL3 as required. This option defaults to ``0``.
 
+-  ``ENABLE_PIE``: Boolean option to enable Position Independent Executable(PIE)
+   support within generic code in TF-A. This option is currently only supported
+   in BL31. Default is 0.
+
 -  ``ENABLE_PMF``: Boolean option to enable support for optional Performance
    Measurement Framework(PMF). Default is 0.
 
index 435de20e3edc36ea6b0b6e7e1187c6e0d0831c6f..4a3f54116ad51a1d3c0005969ab8e5f1f41b8f5f 100644 (file)
@@ -64,6 +64,9 @@ DYN_DISABLE_AUTH              := 0
 # Build option to enable MPAM for lower ELs
 ENABLE_MPAM_FOR_LOWER_ELS      := 0
 
+# Flag to Enable Position Independant support (PIE)
+ENABLE_PIE                     := 0
+
 # Flag to enable Performance Measurement Framework
 ENABLE_PMF                     := 0